
 package com.ami.vmedia.gui;
 
 import com.ami.iusb.IUSBRedirSession;
 import com.ami.kvm.jviewer.JViewer;
 import com.ami.kvm.jviewer.gui.LocaleStrings;
 import com.ami.vmedia.VMApp;
 import java.awt.BorderLayout;
 import java.awt.Dimension;
 import java.awt.GridBagConstraints;
 import java.awt.GridBagLayout;
 import java.awt.Insets;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
 import javax.swing.BorderFactory;
 import javax.swing.ButtonGroup;
 import javax.swing.JButton;
 import javax.swing.JPanel;
 import javax.swing.JRadioButton;
 import javax.swing.JScrollPane;
 import javax.swing.border.Border;
 import javax.swing.border.TitledBorder;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 public class DeviceControlPanel
   extends JPanel
 {
   private final int INSTANCE_PANEL_WIDTH = 400;
   private final int INSTANCE_PANEL_HEIGHT = 120;
   
   private JButton connectButton;
   
   private JScrollPane instanceScrollPane;
   private DevicePanel devicePanel;
   private JPanel connectPanel;
   private JPanel instancePanel;
   private IUSBRedirSession iusbRedirSession;
   private String deviceLabelText;
   private JRadioButton physicalDrive;
   private JRadioButton logicalDrive;
   private ButtonGroup driveSelectionGroup;
   private int deviceIndex;
   private int deviceType;
   private String redirectionSource = null;
   
 
 
   private int devCount;
   
 
 
   private int freeDevCount;
   
 
 
   public DeviceControlPanel(int paramInt1, int paramInt2)
   {
     this.iusbRedirSession = VMApp.getInstance().getIUSBRedirSession();
     this.deviceType = paramInt1;
     this.deviceIndex = paramInt2;
     String[] arrayOfString = VMApp.getInstance().getDeviceDriveList(paramInt1);
     switch (paramInt1) {
     case 0: 
       this.deviceLabelText = LocaleStrings.getString("AJ_1_DCP");
       this.devCount = VMApp.getInstance().getNumCD();
       this.freeDevCount = VMApp.getInstance().getFreeCDNum();
       break;
     case 1: 
       this.deviceLabelText = LocaleStrings.getString("AJ_2_DCP");
       this.devCount = VMApp.getInstance().getNumFD();
       this.freeDevCount = VMApp.getInstance().getFreeFDNum();
       break;
     case 2: 
       this.deviceLabelText = LocaleStrings.getString("AJ_3_DCP");
       this.devCount = VMApp.getInstance().getNumHD();
       this.freeDevCount = VMApp.getInstance().getFreeHDNum();
     }
     
     constructDeviceControlPanel(paramInt2, paramInt1, arrayOfString);
   }
   
 
 
 
 
 
 
 
 
   private void constructDeviceControlPanel(int paramInt1, int paramInt2, String[] paramArrayOfString)
   {
     GridBagConstraints localGridBagConstraints1 = new GridBagConstraints();
     GridBagConstraints localGridBagConstraints2 = new GridBagConstraints();
     
     Border localBorder = BorderFactory.createEtchedBorder();
     
     this.connectButton = createConnectButton(paramInt2, paramInt1);
     this.devicePanel = new DevicePanel(paramArrayOfString, paramInt2, paramInt1);
     this.instanceScrollPane = new JScrollPane(this.devicePanel, 20, 30);
     
     this.instanceScrollPane.setPreferredSize(new Dimension(400, 120));
     
     this.instancePanel = new JPanel();
     this.instancePanel.setLayout(new GridBagLayout());
     localGridBagConstraints1.insets = new Insets(0, 10, 0, 10);
     localGridBagConstraints1.gridx = 0;
     localGridBagConstraints1.gridwidth = 1;
     localGridBagConstraints1.gridheight = 1;
     localGridBagConstraints1.weightx = 0.5D;
     localGridBagConstraints1.gridy = 0;
     TitledBorder localTitledBorder = BorderFactory.createTitledBorder(localBorder, this.deviceLabelText + VMApp.getInstance().getRomanNumber(paramInt1), 0, 1);
     
 
 
 
     this.instancePanel.setBorder(localTitledBorder);
     localGridBagConstraints1.gridwidth = 1;
     localGridBagConstraints1.weightx = 0.7D;
     localGridBagConstraints1.fill = 2;
     this.instancePanel.add(createPhysicalDevPanel(paramInt2), localGridBagConstraints1);
     localGridBagConstraints1.insets = new Insets(0, 10, 0, 10);
     localGridBagConstraints1.gridy = 1;
     this.instancePanel.add(this.instanceScrollPane, localGridBagConstraints1);
     
     this.connectPanel = new JPanel(new BorderLayout(0, 4));
     this.connectPanel.add(this.connectButton, "Center");
     
     localGridBagConstraints1.insets = new Insets(5, 0, 0, 10);
     localGridBagConstraints1.weightx = 0.3D;
     localGridBagConstraints1.gridx = 1;
     this.instancePanel.add(this.connectPanel, localGridBagConstraints1);
     
     setLayout(new GridBagLayout());
     localGridBagConstraints2.insets = new Insets(10, 5, 5, 0);
     localGridBagConstraints2.gridx = 0;
     localGridBagConstraints2.gridwidth = -1;
     localGridBagConstraints2.gridheight = 1;
     localGridBagConstraints2.weightx = 1.0D;
     localGridBagConstraints2.gridy = 0;
     localGridBagConstraints2.anchor = 23;
     localGridBagConstraints2.fill = 2;
     add(this.instancePanel, localGridBagConstraints2);
   }
   
 
 
 
 
 
 
 
 
   private JButton createConnectButton(int paramInt1, int paramInt2)
   {
     JButton localJButton = new JButton(LocaleStrings.getString("AJ_4_DCP"));
     switch (paramInt1) {
     case 0: 
       localJButton.setActionCommand("CONNECT_CD_" + paramInt2);
       break;
     case 1: 
       localJButton.setActionCommand("CONNECT_FD_" + paramInt2);
       break;
     case 2: 
       localJButton.setActionCommand("CONNECT_HD_" + paramInt2);
       break;
     }
     
     
     localJButton.addActionListener(new VMActionListener());
     return localJButton;
   }
   
 
 
   public JScrollPane getInstanceScrollPane()
   {
     return this.instanceScrollPane;
   }
   
 
 
   public JPanel getConnectPanel()
   {
     return this.connectPanel;
   }
   
 
 
   public JButton getConnectButton()
   {
     return this.connectButton;
   }
   
 
 
   public DevicePanel getDevicePanel()
   {
     return this.devicePanel;
   }
   
 
 
   public void setDevicePanel(DevicePanel paramDevicePanel)
   {
     this.devicePanel = paramDevicePanel;
   }
   
 
 
 
   public void updateDeviceControlPanel()
   {
     this.redirectionSource = this.iusbRedirSession.getDeviceRedirSource(this.deviceType, this.deviceIndex);
     
 
     if (this.iusbRedirSession.getDeviceRedirStatus(this.deviceType, this.deviceIndex) == 1)
     {
       this.devicePanel.disableAll();
       this.connectButton.setText(LocaleStrings.getString("AJ_5_DCP"));
       this.devicePanel.selectRadioButton(this.redirectionSource);
 
 
     }
     else if (this.iusbRedirSession.getDeviceStatus(this.deviceType, this.deviceIndex) == 1)
     {
       this.devicePanel.enableAll();
       this.connectButton.setText(LocaleStrings.getString("AJ_4_DCP"));
       this.devicePanel.selectRadioButton(this.redirectionSource);
     }
     if (!JViewer.isVMApp())
       VMApp.getVMPane().updateJVToolbar(this.deviceType);
     VMApp.getVMPane().physicalDriveChangeState(this.deviceType, this.deviceIndex, this.redirectionSource, false);
   }
   
 
 
 
 
 
 
 
 
 
   private JPanel createPhysicalDevPanel(int paramInt)
   {
     RadioButtonListener localRadioButtonListener = new RadioButtonListener();
     JPanel localJPanel = new JPanel();
     
     localJPanel.setLayout(new GridBagLayout());
     GridBagConstraints localGridBagConstraints = new GridBagConstraints();
     if (paramInt == 2)
     {
 
       if ((JViewer.IsClientAdmin()) && (System.getProperty("os.name").toLowerCase().contains("windows"))) {
         this.driveSelectionGroup = new ButtonGroup();
         this.physicalDrive = new JRadioButton(LocaleStrings.getString("A_5_DP"));
         this.physicalDrive.addActionListener(localRadioButtonListener);
         this.driveSelectionGroup.add(this.physicalDrive);
         this.physicalDrive.setSelected(true);
         localJPanel.add(this.physicalDrive, localGridBagConstraints);
         this.logicalDrive = new JRadioButton(LocaleStrings.getString("A_6_DP"));
         this.logicalDrive.addActionListener(localRadioButtonListener);
         this.driveSelectionGroup.add(this.logicalDrive);
         localJPanel.add(this.logicalDrive, localGridBagConstraints);
       }
     }
     return localJPanel;
   }
   
   class RadioButtonListener
     implements ActionListener
   {
     RadioButtonListener() {}
     
     public void actionPerformed(ActionEvent paramActionEvent)
     {
       JRadioButton localJRadioButton = (JRadioButton)paramActionEvent.getSource();
       if (localJRadioButton.getText().startsWith(DevicePanel.PHYSICAL_DRIVE_WIN)) {
         DeviceControlPanel.this.getDevicePanel().enableHardDiskDrives(DevicePanel.PHYSICAL_DRIVE_WIN);
       }
       else if (localJRadioButton.getText().startsWith(DevicePanel.LOGICAL_DRIVE_WIN)) {
         DeviceControlPanel.this.getDevicePanel().enableHardDiskDrives(DevicePanel.LOGICAL_DRIVE_WIN);
       }
       DeviceControlPanel.this.getDevicePanel().revalidate();
       DeviceControlPanel.this.getDevicePanel().repaint();
     }
   }
 }


/* Location:              D:\Users\tianlin\Downloads\JViewer.jar!\com\ami\vmedia\gui\DeviceControlPanel.class
 * Java compiler version: 5 (49.0)
 * JD-Core Version:       0.7.1
 */